Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid writing NaN and Infinity with json format table #24558

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sug-ghosh
Copy link

fixes #20395 #20395

This pr will fix inserting NaN and Infinity into table as Json Format.

Screenshot 2024-12-22 at 7 22 08 PM Screenshot 2024-12-22 at 7 22 24 PM

In hive, if we insert NaN or Infinity in json format table, it would store that as NULL, which readable from Trino. We can go that path also if we want to create table to be successful.

@ebyhr @hashhar

Description

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`issuenumber`)

Copy link
Member

@ebyhr ebyhr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test?

@@ -123,7 +123,16 @@ else if (REAL.equals(type)) {
return (generator, block, position) -> generator.writeNumber(REAL.getFloat(block, position));
}
else if (DOUBLE.equals(type)) {
return (generator, block, position) -> generator.writeNumber(DOUBLE.getDouble(block, position));
return (generator, block, position) -> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about REAL type?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'NaN' and 'Infinity' getting casted as Double it seems. It goes through double datatype.

Copy link
Member

@ebyhr ebyhr Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. Please try CREATE TABLE test_nan WITH (format = 'json') AS SELECT real 'NaN' a;.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Hive connector can write numeric NaN and ±infinity with JSON format, but can't read the value
2 participants